<?php
namespace app\api\model\order;
use think\facade\Db;
class OrderAuction{
	
	public function insertOrder($_data){
		return Db::name("auction_opus_order")->insert($_data,true);
	}
	
	public function findOrder($_where,$_field){
		return Db::name("auction_opus_order")->where($_where)->field($_field)->find();
		
	}
	public function insertOrderLog($_data)
	{
		return Db::name("auction_opus_order_log")->insert($_data);
	}
	
	public function updateOrder($_up,$_where){
		return Db::name("auction_opus_order")->where($_where)->update($_up);
	}
	
	public function findOrderData($_where,$_field){
		return Db::name("auction_opus_order")->alias("o")
				->join("auction_opus ao","ao.id=o.auction_opus_id")
				->join("auction_opus_details d","d.auction_opus_id=ao.id")
				->join("opus opus","opus.id=ao.opus_id")
				->join("opus_number n","n.id=ao.opus_number_id")
				->where($_where)
				->field($_field)
				->find();
	}
	
	public function selectOrderData($_where,$_field,$_limit,$_order){
		$_data=Db::name("auction_opus_order")->alias("o")
				->join("auction_opus ao","ao.id=o.auction_opus_id")
				->join("auction_opus_details d","d.auction_opus_id=ao.id")
				->join("opus opus","opus.id=ao.opus_id")
				->join("opus_number n","n.id=ao.opus_number_id")
				->where($_where)
				->field($_field)
				->limit(current($_limit),end($_limit))
				->order($_order)
				->select();
		return empty($_data)?:$_data->toArray();		
	}
	
	public function selectOrderLog($_where,$_field){
		$_data=Db::name("auction_opus_order_log")->where($_where)->field($_field)->select();
		return empty($_data)?:$_data->toArray();
	}
	
	public function selectOrder($_where,$_field){
		$_data=Db::name("auction_opus_order")->where($_where)->field($_field)->select();
		return empty($_data)?:$_data->toArray();
	}
	
	
}
?>